import React, { useState, useEffect } from 'react'
import { View, Image, Text } from '@tarojs/components'
import { AtDivider } from 'taro-ui'
import ToLogin from '../../compontents/toLogin'
import Taro from '@tarojs/taro'
import useModel from 'flooks';
import store from '../../stores/index'
import './index.less'
import "taro-ui/dist/style/components/divider.scss";
import "taro-ui/dist/style/components/icon.scss";

import api from '../../http/api'
const { nsBusinessDetail } = api

import TopInfo from './topInfo'
import NsForm from './nsForm'
import NsFooter from './footer'
import TelChoice from './telChoice'


export default (props: any) => {
  const id: any = props.tid.split('nsBusinessId=')[1].split('&')[0]
  const nsTypeId = props.tid.split('nsTypeId=')[1].split('&')[0]
  const telType = props.tid.split('telType=')[1].split('&')[0]
  const price = props.tid.split('price=')[1].split('&')[0]
  const infoList = props.tid.split('infoList=')[1].split('&')[0]
  const [data, setData] = useState({})
  useEffect(() => {
    nsBusinessDetail({ id }).then((res: any) => {
      setData(res.data)
    })
  }, [])
  return (
    <View className='nsBusiness'>
      <ToLogin url={`/pages/nsBusinessDetail/index?nsBusinessId=${id}&nsTypeId=${nsTypeId}&telType=${telType}&price=${price}&infoList=${infoList}`}></ToLogin>
      <TopInfo nsTypeId={nsTypeId} telType={parseInt(telType)} price={price} data={data}></TopInfo>
      <NsForm data={data}></NsForm>
      {
        parseInt(nsTypeId) === 3 && <TelChoice telType={telType} price={price} infoList={infoList}></TelChoice>
      }
       <AtDivider  height={300} content='没有更多了' fontColor='#ccc' fontSize={20}  />
      <NsFooter nsBusinessId={id} nsTypeId={nsTypeId} telType={telType} price={price} data={data} infoList={infoList}></NsFooter>
    </View>
  );
};
